<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>注册</title>
		<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
		</script>
		<script>
			//本地地址
			var localhostUrl="http://localhost:8080/";
			//服务器地址
			//var localhostUrl="http://101.42.48.35/"
			$(document).ready(function() {
				$("#register").click(function() {
					var account=document.getElementById("root").value;
				    var pwd=document.getElementById("pwd").value;
					var profession=$('input[name="zhiye"]:checked').val();
					$.ajax({
						url: localhostUrl+"xiezhewan/register",
						type: "POST",
						contentType: "application/json;charset=UTF-8",
						dataType: "json",
						data: JSON.stringify({
							"user_account": account,
							"user_pwd": pwd,
							"user_profession": profession
						}),
						success: function(result) {
						var json= JSON.parse(JSON.stringify(result));
							if(json.code=="9999"){
								alert(json.data);
							}else{
								alert("注册成功，返回登录页面进入游戏");
									window.location.href='login.html'
							}
							
						}
					});
				});
			 
				$("#fanhui").click(function() {
					  window.location.href='login.html'
				});
			});
			
			
		</script>
	</head>
	<body>

		<div id="div1">

			<ul>账号：<input type="text" id="root"></input></ul>
			<ul>密码：<input type="text" id="pwd"></input></ul>
			<ul>
				<form>
					职业：
					<input type="radio" name='zhiye' id="profession" value="1" checked="checked">1.战士</input>
					<input type="radio" name='zhiye' id="profession" value="2">2.法师</input>
				</form>

			</ul>

			<ul> <button id="register">注册</button> <button id="fanhui">返回登录</button></ul>
		</div>


	</body>
</html>
